package com.soupinabox;

import java.util.ArrayList;

/**
 * Tracker.java
 * <p/>
 * Author:  Taw
 * Date:    4/21/14
 */
public class Tracker {

    public boolean connected = false;

    public ArrayList<ItemReference> build = new ArrayList<ItemReference>();

    public ArrayList<Item> toBeAdded = new ArrayList<Item>();
    public ArrayList<Item> toBeRemoved = new ArrayList<Item>();

    public String host; //The name of the host for this tracker
    public String name; //The unique name of this tracker


    public void addItem(Item... items){
        for(Item i:items){
            build.add(new ItemReference(i));
            //toBeRemoved.remove(i); //TODO: Is this needed?
        }
    }

    public void removeItem(Item... items){
        for(Item item:items){
            for(int i=build.size()-1;i>=0;i--){
                if(build.get(i).item.index == item.index){
                    build.remove(i);
                    break;
                }
            }
        }
    }

    public void clearAll(){
        build.clear();
        toBeAdded.clear();
        toBeRemoved.clear();
        //TODO: Alert connection of clear command
    }

    public void clearBuild(){
        build.clear();
    }

    public boolean isHosting(){
        return false;
    }



}
